package com.br.utils;

import org.json.JSONObject;

import com.br.entities.Player;

public class BufferUtils {
	
	public static JSONObject montarPlayer(String tipo, Player player){
		JSONObject p = new JSONObject();
		
		p.put("tipo", tipo);
		
		p.put("tileX", player.getTileX());
		p.put("tileY", player.getTileY());
		p.put("life", player.getLife());
		p.put("mana", player.getMana());
		p.put("exp", player.getExp());
		p.put("level", player.getLevel());
		p.put("sprite", player.getSprite());
		p.put("username", player.getUsername());
		
		return p;
	}
	
	public static JSONObject montarMovimento(String username, int x, int y, int toX, int toY, int direction){
		JSONObject mv = new JSONObject();
		
		mv.put("tipo", TiposMensagensEnviar.OTHER_PLAYER_MOVE);
		
		mv.put("username", username);
		mv.put("x", x);
		mv.put("y", y);
		mv.put("toX", toX);
		mv.put("toY", toY);
		mv.put("direction", direction);
		
		return mv;
	}
	
	public static JSONObject desconectarOtherPlayer(String username){
		JSONObject mv = new JSONObject();
		
		mv.put("tipo", TiposMensagensEnviar.OTHER_PLAYER_DISCONECTED);
		
		mv.put("username", username);
		
		return mv;
	}

}
